import { CopyControllerBase } from "./CopyControllerBase";
import { CopyFairylandPropPanel } from "../CopyFairylandPropPanel";
import { FairylandItemShowPanel } from "../FairylandItemShowPanel";
import { TCopy } from "../../../../../Message/Db/Tables/TCopy";
import { Global } from "../../../../../com/gengine/global/Global";
import { SystemSetter } from "../../system/SystemSetter";
import { FairylandTreasureData } from "../FairylandTreasureData";
import { GameController } from "../../../mvc/GameController";
import { ItemData } from "../../../resource/info/ItemData";
import { ColorConfig } from "../../../resource/ColorConfig";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
//class CopyFairyController
    
    export  class CopyFairyController extends CopyControllerBase
    {
        constructor()
        {
            super();
            return;
        }

        public get fairylandPropPanel(): CopyFairylandPropPanel
        {
            if (this._fairylandPropPanel == null) 
            {
                this._fairylandPropPanel = new CopyFairylandPropPanel();
            }
            return this._fairylandPropPanel;
        }

        public get fairylandItemShowPanel(): FairylandItemShowPanel
        {
            if (this._fairylandItemShowPanel == null) 
            {
                this._fairylandItemShowPanel = new FairylandItemShowPanel();
            }
            return this._fairylandItemShowPanel;
        }

        public /* override */ enterCopy(arg1: TCopy): void
        {
            super.enterCopy(arg1);
            if (this._fairylandPropPanel == null) 
            {
                this._fairylandPropPanel = new CopyFairylandPropPanel();
            }
            this._fairylandPropPanel.show(Global.stage.stageWidth - 380 - this._fairylandPropPanel.width, 10);
            if (!SystemSetter.localSetter.isGuideUse) 
            {
                this._fairylandPropPanel.showGuideArrow();
            }
            if (this._fairylandItemShowPanel == null) 
            {
                this._fairylandItemShowPanel = new FairylandItemShowPanel();
            }
            this._fairylandItemShowPanel.show(2, 145);
            FairylandTreasureData.treasureInfos.length = 0;
            this._fairylandItemShowPanel.update(FairylandTreasureData.treasureInfos);
            GameController.treasureWarehourse.treasureWarehourse.isInFairylandCopy = true;
            GameController.treasureWarehourse.treasureWarehourse.setTakeOutBtnEnabled(false);
            return;
        }

        public /* override */ leaveCopy(): void
        {
            var loc3=null;
            var loc4=null;
            super.leaveCopy();
            if (this._fairylandPropPanel) 
            {
                this._fairylandPropPanel.hide();
            }
            if (this._fairylandItemShowPanel) 
            {
                this._fairylandItemShowPanel.hide();
            }
            if (cache.pack.treasurePackCache._allItems != null) 
            {
                cache.pack.treasurePackCopy.setAllItems(cache.pack.treasurePackCache._allItems.concat(), cache.pack.treasurePackCache.capacity);
            }
            GameController.treasureWarehourse.treasureWarehourse.isInFairylandCopy = false;
            GameController.treasureWarehourse.treasureWarehourse.updateModule();
            GameController.treasureWarehourse.treasureWarehourse.setTakeOutBtnEnabled(true);
            var loc1=FairylandTreasureData.itemDatas;
            var loc2=loc1.length;
            var loc5=0;
            while (loc5 < loc2) 
            {
                loc3 = loc1[loc5] as ItemData;
                loc4 = ColorConfig.instance.getItemColor(loc3.itemInfo.item.color);
                MsgManager.addTipText(Language.getStringByParam(60022, loc3.itemAmount) + HTMLUtil.addColor(loc3.itemInfo.item.name, loc4.color));
                ++loc5;
            }
            FairylandTreasureData.itemDatas.length = 0;
            return;
        }

        public /* override */ stageResize(): void
        {
            if (this._fairylandPropPanel && !this._fairylandPropPanel.isHide) 
            {
                this._fairylandPropPanel.show(Global.stage.stageWidth - 380 - this._fairylandPropPanel.width, 10);
            }
            if (this._fairylandItemShowPanel && !this._fairylandItemShowPanel.isHide) 
            {
                this._fairylandItemShowPanel.show(2, 145);
            }
            return;
        }

        /* internal */ /* var */_fairylandPropPanel: CopyFairylandPropPanel;

        /* internal */ /* var */_fairylandItemShowPanel: FairylandItemShowPanel;
    }
